package org.example.doctorapi.controller;

import org.example.doctorapi.data.SysDept;
import org.example.doctorapi.server.SysDeptServer;
import org.example.doctorcommon.util.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/dept")
public class SysDeptController {
    @Autowired
    private SysDeptServer sysDeptServer;

    @GetMapping("/listDeptForPage")
    public BaseResult listDeptForPage(@Validated SysDept sysDept){
        return BaseResult.ok(sysDeptServer.getDict(sysDept));
    }
    @PostMapping("/addDept")
    public BaseResult addDept(@Validated SysDept sysDept){
        sysDeptServer.insertOne(sysDept);
        return BaseResult.ok("添加成功");
    }

    @PostMapping("/updateDept")
    public BaseResult updateDept(@Validated SysDept sysDept){
        sysDeptServer.updateOne(sysDept);
        return BaseResult.ok("跟新成功");
    }

    @DeleteMapping("/delete")
    public BaseResult delete(List<Integer> dis){
        sysDeptServer.deleteList(dis);
        return BaseResult.ok("删除成功");
    }


}
